package epoverty;

import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.security.NoSuchAlgorithmException;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.DefaultTableModel;
import net.miginfocom.swing.MigLayout;

public final class EPovertyMain extends JFrame
{
   // ACCOUNTID NUMBERS
   private final int OVERHEAD = 1;
   private final int TRIPS = 2;
   private final int CHARITY = 3;
   private JPanel mainPanel;
   private JTabbedPane tabs;
   public static JLabel messages;
   private EPovertyMain.myTable fundraisersTable;
   // OBJECT ARAYS FOR GRAPHING THE CHARTS and VARIABLE FOR HOW MANY MONTHS TO DO
   private final int NUMBER_OF_MONTHS_TO_GRAPH = 6;
   Object[] months;
   Object[] donationsData;
   Object[] withdrawalsData;
   //********************************************* ALL TABBED IMAGES
   private BufferedImage homeTAB = ImageIO.read(new File("homeTAB.jpg"));
   private BufferedImage homeTABselected = ImageIO.read(new File("homeTABselected.jpg"));
   private BufferedImage fundraisersTAB = ImageIO.read(new File("fundraisersTAB.jpg"));
   private BufferedImage fundraisersTABselected = ImageIO.read(new File("fundraisersTABselected.jpg"));
   private BufferedImage donorsTAB = ImageIO.read(new File("donorsTAB.jpg"));
   private BufferedImage donorsTABselected = ImageIO.read(new File("donorsTABselected.jpg"));
   private BufferedImage donationsTAB = ImageIO.read(new File("donationsTAB.jpg"));
   private BufferedImage donationsTABselected = ImageIO.read(new File("donationsTABselected.jpg"));
   private BufferedImage accountsTAB = ImageIO.read(new File("accountsTAB.jpg"));
   private BufferedImage accountsTABselected = ImageIO.read(new File("accountsTABselected.jpg"));
   private BufferedImage transactionsTAB = ImageIO.read(new File("transactionsTAB.jpg"));
   private BufferedImage transactionsTABselected = ImageIO.read(new File("transactionsTABselected.jpg"));
   private BufferedImage tripsTAB = ImageIO.read(new File("tripsTAB.jpg"));
   private BufferedImage tripsTABselected = ImageIO.read(new File("tripsTABselected.jpg"));
   private BufferedImage charity$TAB = ImageIO.read(new File("charity$TAB.jpg"));
   private BufferedImage charity$TABselected = ImageIO.read(new File("charity$TABselected.jpg"));
   private BufferedImage overhead$TAB = ImageIO.read(new File("overhead$TAB.jpg"));
   private BufferedImage overhead$TABselected = ImageIO.read(new File("overhead$TABselected.jpg"));
   private BufferedImage trips$TAB = ImageIO.read(new File("trips$TAB.jpg"));
   private BufferedImage trips$TABselected = ImageIO.read(new File("trips$TABselected.jpg"));
   //*********************************************Colors used in the program that are not found in the Colors class
   public static final Color darkest = new Color(35, 35, 35);
   public static final Color font = new Color(195, 195, 195);
   Border borderGreen = BorderFactory.createLineBorder(Color.GREEN);
   Border borderGray = BorderFactory.createLineBorder(Color.LIGHT_GRAY);
   Border left = BorderFactory.createMatteBorder(4, 4, 4, 0, Color.DARK_GRAY);
   Border right = BorderFactory.createMatteBorder(4, 0, 4, 4, Color.DARK_GRAY);
   //Tabbed Components (make global so listeners can interact with them)
   private AccountsSummary accountsPanel;
   public JMenuItem distributionJMI;

   //*********************************************CONSTRUCTOR METHOD
   public EPovertyMain() throws IOException, ClassNotFoundException, SQLException, ParseException
   {
      // SET UP UI
      UIManager.put("Table.background", Color.DARK_GRAY);
      UIManager.put("Table.foreground", Color.WHITE);
      UIManager.put("Table.font", new Font("SansSerif", Font.BOLD, 14));
      UIManager.put("Table.selectionBackground", Color.GREEN);
      UIManager.put("Table.selectionForeground", Color.BLACK);
      UIManager.put("Table.gridColor", Color.BLACK);
      UIManager.put("TableHeader.background", Color.GRAY);
      UIManager.put("TableHeader.foreground", Color.GREEN);
      UIManager.put("TableHeader.font", new Font("SansSerif", Font.BOLD, 16));
      UIManager.put("TextField.caretForeground", Color.WHITE);
      UIManager.put("TextField.margin", new Insets(0, 2, 0, 2));
      UIManager.put("TextArea.caretForeground", Color.WHITE);
      UIManager.put("TextArea.margin", new Insets(0, 2, 0, 2));
      UIManager.put("Label.foreground", Color.GREEN);
      UIManager.put("Label.font", new Font("Serif", Font.BOLD, 16));
      UIManager.put("TextArea.background", Color.GRAY);
      UIManager.put("TextArea.foreground", Color.WHITE);
      UIManager.put("TabbedPane.selected", Color.DARK_GRAY);
      UIManager.put("Slider.border", borderGreen);
      UIManager.put("Slider.altTrackColor", Color.GREEN);
      UIManager.put("Slider.background", Color.GRAY);
      UIManager.put("MenuBar.background", darkest);
      UIManager.put("MenuBar.borderColor", Color.GREEN);
      UIManager.put("MenuBar.foreground", Color.WHITE);
      UIManager.put("MenuBar.shadow", Color.DARK_GRAY);
      UIManager.put("Menu.opaque", true);
      UIManager.put("Menu.border", borderGreen);
      UIManager.put("Menu.background", Color.DARK_GRAY);
      UIManager.put("Menu.selectionBackground", darkest);
      UIManager.put("Menu.foreground", Color.WHITE);
      UIManager.put("Menu.selectionForeground", Color.WHITE);
      UIManager.put("MenuItem.border", borderGreen);
      UIManager.put("MenuItem.background", Color.DARK_GRAY);
      UIManager.put("MenuItem.selectionBackground", darkest);
      UIManager.put("MenuItem.foreground", Color.WHITE);
      UIManager.put("MenuItem.selectionForeground", Color.WHITE);

      //CREATE MAIN PANEL
      setTitle("|||E-Poverty Main || V-0.1 (SKELETON)|||");
      setSize(1200, 780);
      setLocation(0, 0);
      setVisible(true);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      mainPanel = new JPanel();
      setContentPane(mainPanel);
      mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS));
      mainPanel.setBackground(darkest);

      //******************************************CREATE THE TOP PANEL
      BackgroundPanel topPanel = new BackgroundPanel(null, BackgroundPanel.ACTUAL, 1.0f, 0.5f);
      topPanel.setLayout(new GridLayout(1, 2, 0, 0));
      Dimension top = new Dimension(super.getWidth(), super.getHeight() - 15);
      topPanel.setPreferredSize(top);

      //CREATE THE BOTTOM 'STATUS' PANEL AND ADD A LABEL TO IT FOR MESSAGES
      BackgroundPanel bottomPanel = new BackgroundPanel(null, BackgroundPanel.ACTUAL, 1.0f, 0.5f);
      Dimension bottom = new Dimension(5000, 15);
      bottomPanel.setPreferredSize(bottom);
      bottomPanel.setMaximumSize(bottom);
      GradientPaint paintBottom = new GradientPaint(0, 0, Color.BLACK, 200, 0, Color.WHITE);
      bottomPanel.setPaint(paintBottom);
      bottomPanel.setLayout(new GridBagLayout());
      GridBagConstraints gBC = new GridBagConstraints();
      gBC.fill = GridBagConstraints.NONE;
      messages = new JLabel("");
      gBC.insets = new Insets(0, 0, 0, 5);
      gBC.anchor = GridBagConstraints.EAST;
      gBC.weightx = 0.5;
      gBC.gridx = 10;
      gBC.gridy = 0;
      gBC.gridwidth = 1;
      messages.setForeground(Color.BLACK);
      bottomPanel.add(messages, gBC);

      /*
       * HOME TAB
       */
      BackgroundPanel homeTab = new BackgroundPanel(null, BackgroundPanel.ACTUAL, 50.0f, 10.5f);
      homeTab.setLayout(new GridLayout(2, 2, 0, 0));
      Dimension access = new Dimension(super.getWidth(), super.getHeight() - 15);
      homeTab.setPreferredSize(access);
      GradientPaint paintAccess = new GradientPaint(0, 0, Color.BLACK, 100, 100, Color.BLACK);
      homeTab.setPaint(paintAccess);

      //******************************************SET UP THE GRAPHS
      months = DBconnection.getMonths(NUMBER_OF_MONTHS_TO_GRAPH);
      donationsData = DBconnection.getMonthlyDonations(months);
      withdrawalsData = DBconnection.getMonthlyWithdrawals(months);
      BarGraph donationsGraph = new BarGraph("Monthly Donations", months, donationsData);
      donationsGraph.setGradient(Color.LIGHT_GRAY, Color.DARK_GRAY);
      donationsGraph.setGridColor(Color.WHITE);
      donationsGraph.setTextColor(Color.GREEN);
      donationsGraph.setBarColor(Color.BLACK);
      donationsGraph.setBarOpacity(150);
      donationsGraph.setBorder(borderGreen);
      BarGraph withdrawalsGraph = new BarGraph("Monthly Withdrawals", months, withdrawalsData);
      withdrawalsGraph.setGradient(Color.LIGHT_GRAY, Color.DARK_GRAY);
      withdrawalsGraph.setGridColor(Color.WHITE);
      withdrawalsGraph.setTextColor(Color.GREEN);
      withdrawalsGraph.setBarColor(Color.BLACK);
      withdrawalsGraph.setBarOpacity(150);
      withdrawalsGraph.setBorder(borderGreen);

      // *****************************************SET UP UPCOMMING DATES PANEL
      JPanel upcommingDates = new JPanel();
      JLabel labelHeader = new JLabel("Upcomming Trip Dates", JLabel.CENTER);
      labelHeader.setForeground(Color.WHITE);

      JLabel labelCutoff = new JLabel("Next Cutoff Date:", JLabel.CENTER);
      labelCutoff.setBorder(left);
      String cutoff = DBconnection.getNextCutoffDate().toString();
      JLabel cutoffText = new JLabel("", JLabel.LEFT); 
      if (cutoff.length() > 2)
      {
        cutoffText.setText(cutoff.substring(2, cutoff.length() - 2));
      }
      cutoffText.setBorder(right);

      JLabel labelDepart = new JLabel("Next Depart Date:", JLabel.CENTER);
      labelDepart.setBorder(left);
      String depart = DBconnection.getNextDepartDate().toString();
      JLabel departText = new JLabel("", JLabel.LEFT);
      if (depart.length() > 2)
      {
        departText.setText(depart.substring(2, depart.length() - 2));
      }
      departText.setBorder(right);

      JLabel labelReturn = new JLabel("Next Return Date:", JLabel.CENTER);
      labelReturn.setBorder(left);
      String retrn = DBconnection.getNextReturnDate().toString();
      JLabel returnText = new JLabel("", JLabel.LEFT);
      if (retrn.length() > 2)
      {
        returnText.setText((retrn.substring(2, retrn.length() - 2)));
      }
      returnText.setBorder(right);

      JLabel totalTrips = new JLabel("Total Planned Trips:", JLabel.CENTER);
      totalTrips.setBorder(left);
      JLabel tripCount = new JLabel(DBconnection.getTripCount() + "", JLabel.LEFT);
      tripCount.setBorder(right);

      upcommingDates.setLayout(new GridLayout(8, 2, 0, 2));
      upcommingDates.add(labelHeader);
      upcommingDates.add(new JLabel(""));
      upcommingDates.add(labelCutoff);
      upcommingDates.add(cutoffText);
      upcommingDates.add(labelDepart);
      upcommingDates.add(departText);
      upcommingDates.add(labelReturn);
      upcommingDates.add(returnText);
      upcommingDates.add(new JLabel(""));
      upcommingDates.add(new JLabel(""));
      upcommingDates.add(new JLabel(""));
      upcommingDates.add(new JLabel(""));
      upcommingDates.add(new JLabel(""));
      upcommingDates.add(new JLabel(""));
      upcommingDates.add(totalTrips);
      upcommingDates.add(tripCount);
      upcommingDates.setBorder(borderGray);

      // *****************************************SET UP RECENT FUNDRAISERS PANEL
      JPanel recentFundraiser = new JPanel();

      JLabel labelHeaderFund = new JLabel("Recent Fundraisers who have met their goal", JLabel.CENTER);
      labelHeaderFund.setForeground(Color.WHITE);
      fundraisersTable = new EPovertyMain.myTable();
      JTable successfullFundraiser = new JTable(fundraisersTable);
      JScrollPane tablePane = new JScrollPane(successfullFundraiser);
      fundraisersTable = DBconnection.getRecentGoalReachers(fundraisersTable);
      fundraisersTable.fireTableDataChanged();

      recentFundraiser.setLayout(new MigLayout(
         "wrap 1, insets 0 10 0 10",
         "[center]",
         "[]2[grow][][]"));

      recentFundraiser.add(labelHeaderFund, "grow, width 475:475:, height 25!");

      successfullFundraiser.enableInputMethods(false);
      successfullFundraiser.setFillsViewportHeight(true);
      recentFundraiser.add(tablePane, "grow, width 475:475:, height 300!");
      recentFundraiser.setBorder(borderGray);

      homeTab.add(donationsGraph);
      homeTab.add(upcommingDates);
      homeTab.add(recentFundraiser);
      homeTab.add(withdrawalsGraph);

      //******************************************CREATE TABS and EDIT THEIR APPEARANCE
      tabs = new JTabbedPane();
      tabs.setTabPlacement(JTabbedPane.LEFT);
      tabs.setBackground(Color.DARK_GRAY);
      tabs.updateUI();
      mainPanel.add(tabs);

      //******************************************CALL EACH TABS CLASS (SENDING IT THE JTABBEDPANE OBJECT)
      tabs.add("", homeTab);
      Fundraisers fundraisers = new Fundraisers(tabs);
      Donors donors = new Donors(tabs);
      Donations donations = new Donations(tabs);
      Withdrawals transactions = new Withdrawals(tabs);
      Trips trips = new Trips(tabs);
      accountsPanel = new AccountsSummary(tabs, this);
      CharityFunds charity = new CharityFunds(tabs);
      OverheadFunds overhead = new OverheadFunds(tabs);
      IndividualTripFunds individual = new IndividualTripFunds(tabs);

      //******************************************ADD ICONS TO TABS (Changing Tab location above will NOT change their image)
      tabs.setIconAt(0, new ImageIcon(homeTABselected));
      tabs.setIconAt(1, new ImageIcon(fundraisersTAB));
      tabs.setIconAt(2, new ImageIcon(donorsTAB));
      tabs.setIconAt(3, new ImageIcon(donationsTAB));
      tabs.setIconAt(4, new ImageIcon(transactionsTAB));
      tabs.setIconAt(5, new ImageIcon(tripsTAB));
      tabs.setIconAt(6, new ImageIcon(accountsTAB));
      tabs.setIconAt(7, new ImageIcon(charity$TAB));
      tabs.setIconAt(8, new ImageIcon(overhead$TAB));
      tabs.setIconAt(9, new ImageIcon(trips$TAB));

      //******************************************LISTENER FOR THE TABS (TO CHANGE ICONS WHEN SELECTED)
      tabs.addChangeListener(new ChangeListener()
      {
         @Override
         public void stateChanged(ChangeEvent e)
         {
            // RESET ALL TABS TO THEIR 'UNSELECTED' FORM
            tabs.setIconAt(0, new ImageIcon(homeTAB));
            tabs.setIconAt(1, new ImageIcon(fundraisersTAB));
            tabs.setIconAt(2, new ImageIcon(donorsTAB));
            tabs.setIconAt(3, new ImageIcon(donationsTAB));
            tabs.setIconAt(4, new ImageIcon(transactionsTAB));
            tabs.setIconAt(5, new ImageIcon(tripsTAB));
            tabs.setIconAt(6, new ImageIcon(accountsTAB));
            tabs.setIconAt(7, new ImageIcon(charity$TAB));
            tabs.setIconAt(8, new ImageIcon(overhead$TAB));
            tabs.setIconAt(9, new ImageIcon(trips$TAB));

            // GET SELECTED TAB AND CHANGE THE ICON TO THE 'SELECTED' VERSION
            int tabSelected = tabs.getSelectedIndex();
            switch (tabSelected)
            {
               case 0:
                  tabs.setIconAt(0, new ImageIcon(homeTABselected));
                  break;
               case 1:
                  tabs.setIconAt(1, new ImageIcon(fundraisersTABselected));
                  break;
               case 2:
                  tabs.setIconAt(2, new ImageIcon(donorsTABselected));
                  break;
               case 3:
                  tabs.setIconAt(3, new ImageIcon(donationsTABselected));
                  break;
               case 4:
                  tabs.setIconAt(4, new ImageIcon(transactionsTABselected));
                  break;
               case 5:
                  tabs.setIconAt(5, new ImageIcon(tripsTABselected));
                  break;
               case 6:
                  tabs.setIconAt(6, new ImageIcon(accountsTABselected));
                  break;
               case 7:
                  tabs.setIconAt(7, new ImageIcon(charity$TABselected));
                  break;
               case 8:
                  tabs.setIconAt(8, new ImageIcon(overhead$TABselected));
                  break;
               case 9:
                  tabs.setIconAt(9, new ImageIcon(trips$TABselected));
                  break;
               default:
                  break;
            }

         }
      });

      mainPanel.add(bottomPanel);

      //******************************************SET UP MENU BAR
      JMenuBar menuBar = new JMenuBar();
      //menuBar.setBackground(darkest);
      setJMenuBar(menuBar);
      // *****************************************ACCOUNTS MENU
      JMenu accountsMenu = new JMenu("Accounts");
      //accountsMenu.setForeground(Color.WHITE);
      menuBar.add(accountsMenu);
      //SET UP OPTIONS FOR ACCOUNT MENU
      JMenu addDonationJM = new JMenu("Add Donation");
      JMenu addWithdrawalJM = new JMenu("Add Withdrawal");
      distributionJMI = new JMenuItem("Distribution Settings");
      //SUB MENUS FOR ADD DONATION
      JMenuItem addToCharityJMI = new JMenuItem("To Charity");
      JMenuItem addToFundraiserJMI = new JMenuItem("To Fundraiser");
      //SUB MENUS FOR ADD WITHDRAWAL
      JMenuItem withdrawalFromCharityJMI = new JMenuItem("From Charity");
      JMenuItem withdrawalFromOverheadJMI = new JMenuItem("From Overhead");
      JMenuItem withdrawalFromTripsJMI = new JMenuItem("From Trips");
      //ADD MENU ITEMS TO CORRECT SPOTS AND THEN TO THE MAIN MENU
      addDonationJM.add(addToCharityJMI);
      addDonationJM.add(addToFundraiserJMI);
      addWithdrawalJM.add(withdrawalFromCharityJMI);
      addWithdrawalJM.add(withdrawalFromOverheadJMI);
      addWithdrawalJM.add(withdrawalFromTripsJMI);
      accountsMenu.add(addDonationJM);
      accountsMenu.add(addWithdrawalJM);
      accountsMenu.addSeparator();
      accountsMenu.add(distributionJMI);

      // *****************************************TRIPS MENU
      JMenu tripsMenu = new JMenu("Trips");
      menuBar.add(tripsMenu);
      //SET UP OPTIONS FOR TRIPS MENU
      JMenuItem addTripJMI = new JMenuItem("Add Trip");
      JMenuItem editTripJMI = new JMenuItem("Edit Trip");
      JMenuItem addPicturesTripJMI = new JMenuItem("Add Pictures To Trip");
      //ADD MENU ITEMS TO MENU BAR
      tripsMenu.add(addTripJMI);
      tripsMenu.add(editTripJMI);
      tripsMenu.add(addPicturesTripJMI);

      // *****************************************PERSONS MENU
      JMenu personsMenu = new JMenu("Persons");
      menuBar.add(personsMenu);
      //SET UP OPTIONS FOR PERSONS MENU
      JMenuItem addPersonJMI = new JMenuItem("Add Person");
      JMenuItem changeRolesJMI = new JMenuItem("Change Persons Roles");
      //ADD MENUT ITEMS TO MENU BAR
      personsMenu.add(addPersonJMI);
      personsMenu.add(changeRolesJMI);

      // *****************************************REPORTS MENU
      JMenu reportsMenu = new JMenu("Reports");
      menuBar.add(reportsMenu);
      JMenuItem donorsLastDonationJMI = new JMenuItem("Donors Last Donation");
      reportsMenu.add(donorsLastDonationJMI);

      // *****************************************IMPORTS MENU
      JMenu importsMenu = new JMenu("Imports");
      JMenuItem importFromFile = new JMenuItem("Import From A File");
      importFromFile.addActionListener(new ActionListener()
      {
            @Override
            public void actionPerformed(ActionEvent ae)
            {
                DonationImporter importFrame = new DonationImporter();
                importFrame.display();
            }
      });

      importsMenu.add(importFromFile);
      menuBar.add(importsMenu);

      // *****************************************ABOUT MENU
      JMenuItem aboutMenu = new JMenuItem("About");
      aboutMenu.setBackground(darkest);
      menuBar.add(aboutMenu);

      /*
       *
       * AFTER THIS POINT THERE ARE THE LISTENERS
       * FOR THE JMENUITEMS AT THE VERY END OF THE
       * CLASS THERE IS A METHOD TO UPDATE THE
       * STATUS BAR AT THE BOTTOM. NOTHING IS
       * UPDATING THIS AS OF NOW THOUGH.
       *
       */
      // *****************************************LISTENER FOR THE ADD TO CHARITY FUNCTION
      addToCharityJMI.addActionListener(
         new ActionListener()
         {
            ArrayList<Object> donors, donorsFormatted;
            BigDecimal overheadDeposit, charityDeposit;
            double percentToOverhead;

            @Override
            public void actionPerformed(ActionEvent e)
            {
               UIManager.put("OptionPane.okButtonText", "ADD DONATION");

               // INITIALIZE ALL DEPOSITS TO ZERO
               overheadDeposit = new BigDecimal("0.00");
               charityDeposit = new BigDecimal("0.00");

               final JPanel panel = new JPanel(new GridBagLayout());
               GridBagConstraints gBC = new GridBagConstraints();
               final JFrame f = new JFrame();
               f.getContentPane().add(panel);
               f.pack();

               try
               {
                  donors = DBconnection.getDonors();
                  donorsFormatted = ArraySorter.sortArray(donors);
               }
               catch (SQLException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
               catch (ClassNotFoundException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
               SearchableComboBox donorsList = new SearchableComboBox(donorsFormatted.toArray());
               JButton dateBTN = new JButton("Date");
               JTextField amountTF = new JTextField(12);
               final JTextField dateTF = new JTextField(12);
               gBC.anchor = GridBagConstraints.WEST;

               // COLUMN 1
               gBC.weightx = 1;
               gBC.weighty = 1;
               gBC.gridx = 0;
               gBC.gridy = 0;
               panel.add(new JLabel("Amount:"), gBC);

               gBC.gridy = 1;
               panel.add(new JLabel("Donor:"), gBC);

               gBC.gridy = 2;
               panel.add(new JLabel("Date:"), gBC);

               // COLUMN 2
               gBC.gridy = 0;
               gBC.gridx = 1;
               panel.add(amountTF, gBC);

               gBC.gridy = 1;
               panel.add(donorsList, gBC);

               gBC.gridy = 2;
               panel.add(dateTF, gBC);

               // COLUMN 3
               gBC.gridx = 2;
               panel.add(dateBTN, gBC);

               // LISTENER TO BUTTON
               dateBTN.addActionListener(new ActionListener()
               {
                  @Override
                  public void actionPerformed(ActionEvent ae)
                  {
                     dateTF.setText(new DatePicker(f).setPickedDate());
                  }
               });

               int moreInfo = JOptionPane.showConfirmDialog(null, panel, "ADD DONATION TO FUNDRAISER",
                  JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
               // *****************************************IF 'OK' IS HIT VERYIFY.  OTHERWISE CANCEL
               if (moreInfo == JOptionPane.OK_OPTION)
               {
                  // PUT SELECTED DONOR/FUNDRAISER ID's INTO A STRING
                  String donorIDselected = donors.get(donorsList.getSelectedIndex()).toString();
                  String donorID = donorIDselected.substring(donorIDselected.lastIndexOf(',') + 2,
                     donorIDselected.length() - 1);
                  // GET THE REST OF THE INFORMATION INPUT
                  String date = dateTF.getText();
                  BigDecimal amount = new BigDecimal(amountTF.getText());
                  // GET % TO OVERHEAD
                  try
                  {
                     percentToOverhead = DBconnection.getOverheadPercent();
                  }
                  catch (SQLException ex)
                  {
                     Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                  }
                  catch (ClassNotFoundException ex)
                  {
                     Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                  }


                  overheadDeposit = amount.multiply(new BigDecimal(percentToOverhead).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP));
                  charityDeposit = amount.subtract(overheadDeposit);

                  // FORMAT BigDecimals
                  overheadDeposit = overheadDeposit.setScale(2, BigDecimal.ROUND_HALF_UP);
                  charityDeposit = charityDeposit.setScale(2, BigDecimal.ROUND_HALF_UP);

                  // UPDATE ALL NECESSARY TABLES
                  try
                  {
                     // ADD TO DONATIONS TABLE and GET DONATIONID BACK FOR *THIS* DONATION (all in one method)
                     int donationID = 0;
                     try
                     {
                        donationID = DBconnection.addDonation(Integer.parseInt(donorID), 0, date, amount);
                     }
                     catch (ParseException ex)
                     {
                        Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                     }

                     DBconnection.addDeposit(OVERHEAD, donationID, overheadDeposit);
                     DBconnection.addDeposit(CHARITY, donationID, charityDeposit);

                     //UPDATE ACCOUNTS TABLE
                     DBconnection.updateAccountDeposits(OVERHEAD, overheadDeposit);
                     DBconnection.updateAccountDeposits(CHARITY, charityDeposit);
                  }
                  catch (SQLException ex)
                  {
                     Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                  }
                  catch (ClassNotFoundException ex)
                  {
                     Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                  }
               }
            }
         });

      // *****************************************LISTENER FOR THE ADD TO FUNDRAISER FUNCTION
      addToFundraiserJMI.addActionListener(
         new ActionListener()
         {
            ArrayList<Object> fundraisers, donors, fundraisersFormatted, donorsFormatted;
            BigDecimal fundraisersRaiseGoal, fundraisersRaiseTotal, overheadDeposit, charityDeposit, tripsDeposit;
            double percentToOverhead;
            boolean goalReached = false;

            @Override
            public void actionPerformed(ActionEvent e)
            {
               UIManager.put("OptionPane.okButtonText", "ADD DONATION");

               // INITIALIZE ALL DEPOSITS TO ZERO
               overheadDeposit = new BigDecimal("0.00");
               tripsDeposit = new BigDecimal("0.00");
               charityDeposit = new BigDecimal("0.00");

               final JPanel panel = new JPanel(new GridBagLayout());
               GridBagConstraints gBC = new GridBagConstraints();
               final JFrame f = new JFrame();
               f.getContentPane().add(panel);
               f.pack();

               try
               {
                  fundraisers = DBconnection.getFundraisers();
                  donors = DBconnection.getDonors();
                  fundraisersFormatted = ArraySorter.sortArray(fundraisers);
                  donorsFormatted = ArraySorter.sortArray(donors);
               }
               catch (SQLException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
               catch (ClassNotFoundException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
               SearchableComboBox fundraisersList = new SearchableComboBox(fundraisersFormatted.toArray());
               SearchableComboBox donorsList = new SearchableComboBox(donorsFormatted.toArray());
               JButton dateBTN = new JButton("Date");
               JTextField amountTF = new JTextField(12);
               final JTextField dateTF = new JTextField(12);
               gBC.anchor = GridBagConstraints.WEST;

               // COLUMN 1
               gBC.weightx = 1;
               gBC.weighty = 1;
               gBC.gridx = 0;
               gBC.gridy = 0;
               panel.add(new JLabel("Amount:"), gBC);

               gBC.gridy = 1;
               panel.add(new JLabel("Donor:"), gBC);

               gBC.gridy = 2;
               panel.add(new JLabel("Fundraiser:"), gBC);

               gBC.gridy = 3;
               panel.add(new JLabel("Date:"), gBC);

               // COLUMN 2
               gBC.gridy = 0;
               gBC.gridx = 1;
               panel.add(amountTF, gBC);

               gBC.gridy = 1;
               panel.add(donorsList, gBC);

               gBC.gridy = 2;
               panel.add(fundraisersList, gBC);

               gBC.gridy = 3;
               panel.add(dateTF, gBC);

               // COLUMN 3
               gBC.gridx = 2;
               panel.add(dateBTN, gBC);

               // LISTENER TO BUTTON
               dateBTN.addActionListener(new ActionListener()
               {
                  @Override
                  public void actionPerformed(ActionEvent ae)
                  {
                     dateTF.setText(new DatePicker(f).setPickedDate());
                  }
               });

               int moreInfo = JOptionPane.showConfirmDialog(null, panel, "ADD DONATION TO FUNDRAISER",
                  JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
               // *****************************************IF 'OK' IS HIT VERYIFY.  OTHERWISE CANCEL
               if (moreInfo == JOptionPane.OK_OPTION)
               {
                  // PUT SELECTED DONOR/FUNDRAISER ID's INTO A STRING
                  String fundraiserIDselected = fundraisers.get(fundraisersList.getSelectedIndex()).toString();
                  String fundraiserID = fundraiserIDselected.substring(fundraiserIDselected.lastIndexOf(',') + 2,
                     fundraiserIDselected.length() - 1);
                  String donorIDselected = donors.get(donorsList.getSelectedIndex()).toString();
                  String donorID = donorIDselected.substring(donorIDselected.lastIndexOf(',') + 2,
                     donorIDselected.length() - 1);
                  // GET THE REST OF THE INFORMATION INPUT
                  String date = dateTF.getText();
                  String dateMetRaiseGoal = null;
                  BigDecimal amount = new BigDecimal(amountTF.getText());
                  // GET INFO FROM DATABASE TO DETERMINE WHICH ACCOUNT WILL GET HOW MUCH OF THE DONATION
                  try
                  {
                     percentToOverhead = DBconnection.getOverheadPercent();
                     fundraisersRaiseGoal = DBconnection.getFundraisersGoal(Integer.parseInt(fundraiserID));
                     fundraisersRaiseTotal = DBconnection.getFundraisersTotal(Integer.parseInt(fundraiserID));
                  }
                  catch (SQLException ex)
                  {
                     Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                  }
                  catch (ClassNotFoundException ex)
                  {
                     Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                  }

                  /*
                   * / SERIES OF IFS TO DETERMINE
                   * WHAT TABLES NEED TO BE
                   * UPDATED WITH THE DONATION AND
                   * HOW MUCH GOES INTO EACH
                   * ACCOUNT.
                   */
                  // Fundraiser has met their goal
                  if (fundraisersRaiseTotal.compareTo(fundraisersRaiseGoal) == 0
                     || fundraisersRaiseTotal.compareTo(fundraisersRaiseGoal) == 1)
                  {
                     // Since goal has been met, everything after overhead goes to charity
                     overheadDeposit = amount.multiply(new BigDecimal(percentToOverhead).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP));
                     overheadDeposit = overheadDeposit.setScale(2, BigDecimal.ROUND_HALF_UP);
                     charityDeposit = amount.subtract(overheadDeposit);
                  }
                  // Fundraiser has NOT met their goal
                  if (fundraisersRaiseTotal.compareTo(fundraisersRaiseGoal) == -1)
                  {
                     // This donation will not meet or exceede their goal
                     if (fundraisersRaiseTotal.add(amount).compareTo(fundraisersRaiseGoal) == -1)
                     {
                        // Since this donation will not reach their goal all goes to trips after overhead
                        overheadDeposit = amount.multiply(new BigDecimal(percentToOverhead).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP));
                        overheadDeposit = overheadDeposit.setScale(2, BigDecimal.ROUND_HALF_UP);
                        tripsDeposit = amount.subtract(overheadDeposit);
                        tripsDeposit = tripsDeposit.setScale(2, BigDecimal.ROUND_HALF_UP);
                        goalReached = false;
                     }
                     // This donation WILL meet or exceede their goal
                     if (fundraisersRaiseTotal.add(amount).compareTo(fundraisersRaiseGoal) == 0
                        || fundraisersRaiseTotal.add(amount).compareTo(fundraisersRaiseGoal) == 1)
                     {
                        // Since this donation will meet or exceed their goal, all three accounts are effected
                        overheadDeposit = amount.multiply(new BigDecimal(percentToOverhead).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP));
                        overheadDeposit = overheadDeposit.setScale(2, BigDecimal.ROUND_HALF_UP);

                        BigDecimal percentRemaining = BigDecimal.ONE.subtract(new BigDecimal(percentToOverhead).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP));
                        BigDecimal actualDifference = fundraisersRaiseGoal.subtract(fundraisersRaiseTotal).multiply(percentRemaining);
                        tripsDeposit = actualDifference.setScale(2, BigDecimal.ROUND_HALF_UP);

                        charityDeposit = amount.subtract(overheadDeposit).subtract(tripsDeposit);
                        dateMetRaiseGoal = date;
                        goalReached = true;
                     }
                  }
                  // FORMAT BigDecimals
//                  overheadDeposit = overheadDeposit.setScale(2, BigDecimal.ROUND_HALF_UP);
//                  tripsDeposit = tripsDeposit.setScale(2, BigDecimal.ROUND_HALF_UP);
                  charityDeposit = charityDeposit.setScale(2, BigDecimal.ROUND_HALF_UP);

                  /*
                   * CHECKS TO SEE IF THIS IS ALL
                   * WORKING SO FAR (keeping this
                   * in for now so it is easy to
                   * see how the money is being
                   * distributed
                   *
                   */
//                  System.out.println("BigDecimal form of %: " + new BigDecimal(percentToOverhead));
//                  System.out.println("Amount to be deposited: " + amount);
//                  System.out.println("overheadDeposit: " + overheadDeposit);
//                  System.out.println("tripsDeposit: " + tripsDeposit);
//                  System.out.println("charityDeposit: " + charityDeposit);

                  // UPDATE ALL NECESSARY TABLES
                  try
                  {
                     // ADD TO DONATIONS TABLE and GET DONATIONID BACK FOR *THIS* DONATION (all in one method)
                     int donationID = DBconnection.addDonation(Integer.parseInt(donorID), Integer.parseInt(fundraiserID), date, amount);

                     // ADD TO DEPOSITS TABLE
                     if (overheadDeposit.compareTo(new BigDecimal("0")) == 1)
                     {
                        DBconnection.addDeposit(OVERHEAD, donationID, overheadDeposit);

                        //UPDATE ACCOUNTS TABLE
                        DBconnection.updateAccountDeposits(OVERHEAD, overheadDeposit);
                     }
                     if (tripsDeposit.compareTo(new BigDecimal("0")) == 1)
                     {
                        DBconnection.addDeposit(TRIPS, donationID, tripsDeposit);

                        //UPDATE ACCOUNTS TABLE
                        DBconnection.updateAccountDeposits(TRIPS, tripsDeposit);

                        // IF THEIR GOAL IS REACHED, UPDATE dateMetRaiseGoal, and only update to reach goal 100/100
                        if (goalReached)
                        {
                           // UPDATE FUNDRAISER RAISED AMOUNT
                           DBconnection.updateFundraiserRaised(Integer.parseInt(fundraiserID), tripsDeposit);
                           DBconnection.updateFundraisersGoalReached(Integer.parseInt(fundraiserID), dateMetRaiseGoal);
                        }
                        else
                        {
                           // UPDATE FUNDRAISER RAISED AMOUNT WITH TOTAL DONATION
                           DBconnection.updateFundraiserRaised(Integer.parseInt(fundraiserID), amount);
                        }
                     }
                     if (charityDeposit.compareTo(new BigDecimal("0")) == 1)
                     {
                        DBconnection.addDeposit(CHARITY, donationID, charityDeposit);

                        //UPDATE ACCOUNTS TABLE
                        DBconnection.updateAccountDeposits(CHARITY, charityDeposit);
                     }
                  }
                  catch (ParseException ex)
                  {
                     Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                  }
                  catch (SQLException ex)
                  {
                     Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                  }
                  catch (ClassNotFoundException ex)
                  {
                     Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                  }
               }
            }
         });
      // *****************************************LISTENER FOR THE WITHDRAW FROM FROM CHARITY FUNCTION
      withdrawalFromCharityJMI.addActionListener(
         new ActionListener()
         {
            @Override
            public void actionPerformed(ActionEvent e)
            {
               // CALL METHOD TO DISPLAY THE ADD WITHDRAWAL SCREEN SENDING ACCOUNT NUMBER
               try
               {
                  addWithdrawal(CHARITY);
               }
               catch (SQLException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
               catch (ClassNotFoundException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
               catch (ParseException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
            }
         });

      // *****************************************LISTENER FOR THE WITHDRAW FROM FROM OVERHEAD FUNCTION
      withdrawalFromOverheadJMI.addActionListener(
         new ActionListener()
         {
            @Override
            public void actionPerformed(ActionEvent e)
            {
               // CALL METHOD TO DISPLAY THE ADD WITHDRAWAL SCREEN SENDING ACCOUNT NUMBER
               try
               {
                  addWithdrawal(OVERHEAD);
               }
               catch (SQLException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
               catch (ClassNotFoundException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
               catch (ParseException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
            }
         });
      // *****************************************LISTENER FOR THE WITHDRAW FROM FROM TRIPS FUNCTION
      withdrawalFromTripsJMI.addActionListener(
         new ActionListener()
         {
            @Override
            public void actionPerformed(ActionEvent e)
            {
               // CALL METHOD TO DISPLAY THE ADD WITHDRAWAL SCREEN SENDING ACCOUNT NUMBER
               try
               {
                  addWithdrawal(TRIPS);
               }
               catch (SQLException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
               catch (ClassNotFoundException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
               catch (ParseException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
            }
         });
      // *****************************************LISTENER FOR THE DISTRIBUTION SETTINGS FUNCTION
      distributionJMI.addActionListener(
         new ActionListener()
         {
            JLabel percentLabel;
            JSlider percent;
            int percentNumber;

            @Override
            public void actionPerformed(ActionEvent e)
            {
               //CHANGE BUTTON TEXT
               UIManager.put("OptionPane.okButtonText", "SAVE");

               // SET UP PANEL AND CONSTRAINT OBJECT
               final JPanel panel = new JPanel(new GridBagLayout());
               GridBagConstraints gBC = new GridBagConstraints();
               gBC.anchor = GridBagConstraints.WEST;

               // INITIALIZE LABEL AND SLIDER
               try
               {
                  percentNumber = DBconnection.getOverheadPercent();
                  percentLabel = new JLabel(Integer.toString(percentNumber));
                  percent = new JSlider();
                  percent.setMinimum(0);
                  percent.setMaximum(100);
                  percent.setValue(percentNumber);

               }
               catch (SQLException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
               catch (ClassNotFoundException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }

               // ADD LISTENER TO SLIDER
               percent.addChangeListener(
                  new ChangeListener()
                  {
                     @Override
                     public void stateChanged(ChangeEvent ce)
                     {
                        int value = percent.getValue();
                        percentLabel.setText(Integer.toString(value));
                     }
                  });

               // ADD LABELS AND SLIDER TO PANEL

               gBC.gridx = 0;
               gBC.gridy = 0;
               gBC.anchor = GridBagConstraints.EAST;
               panel.add(new JLabel("Percent to Overhead: "), gBC);

               gBC.gridx = 1;
               gBC.anchor = GridBagConstraints.WEST;
               panel.add(percentLabel, gBC);

               gBC.weighty = 1;
               gBC.gridwidth = 2;
               gBC.gridx = 0;
               gBC.gridy = 2;
               panel.add(percent, gBC);

               int result = JOptionPane.showConfirmDialog(null, panel, "Change Distribution",
                  JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);

               // *****************************************IF 'OK' IS HIT VERYIFY.  OTHERWISE CANCEL
               if (result == JOptionPane.OK_OPTION)
               {
                  // CALL TO UPDATE DATABASE
                  try
                  {
                     DBconnection.setOverheadPercent((double) (percent.getValue()));
                     accountsPanel.refreshView();
                  }
                  catch (SQLException ex)
                  {
                     Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                  }
                  catch (ClassNotFoundException ex)
                  {
                     Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                  }
               }
            }
         });

      // *****************************************LISTENER FOR THE EDIT TRIPS FUNCTION
      editTripJMI.addActionListener(
         new ActionListener()
         {
            JTextField searchTF, nameTF, costTF, defaultRaiseGoalTF, departDateTF, returnDateTF, cutoffDateTF;
            JTextArea descriptionTF;
            JButton departBTN, returnBTN, cutoffBTN;
            JComboBox tripList;
            ArrayList<Object> trips, tripsFormatted;
            int tripID;

            @Override
            public void actionPerformed(ActionEvent e)
            {
               UIManager.put("OptionPane.okButtonText", "UPDATE TRIP");
               nameTF = new JTextField(12);
               searchTF = new JTextField(12);
               descriptionTF = new JTextArea(4, 30);
               descriptionTF.setBorder(BorderFactory.createLineBorder(Color.WHITE));
               costTF = new JTextField(12);
               defaultRaiseGoalTF = new JTextField(12);
               departDateTF = new JTextField(12);
               returnDateTF = new JTextField(12);
               cutoffDateTF = new JTextField(12);
               departBTN = new JButton("PICK DATE");
               returnBTN = new JButton("PICK DATE");
               cutoffBTN = new JButton("PICK DATE");
               UIManager.put("TextArea.font", searchTF.getFont());
               try
               {
                  trips = DBconnection.getTrips();
                  tripsFormatted = ArraySorter.sortArray(trips);
               }
               catch (SQLException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
               catch (ClassNotFoundException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
               tripList = new JComboBox(tripsFormatted.toArray());

               final JPanel panel = new JPanel(new GridBagLayout());
               GridBagConstraints gBC = new GridBagConstraints();
               gBC.anchor = GridBagConstraints.WEST;

               // COLUMN 1
               gBC.weightx = 1;
               gBC.weighty = 1;
               gBC.gridx = 0;
               gBC.gridy = 0;
               panel.add(new JLabel("Name:"), gBC);

               gBC.gridy = 1;
               panel.add(new JLabel("Cost:"), gBC);

               gBC.gridy = 2;
               panel.add(new JLabel("Raise Goal:"), gBC);

               gBC.gridy = 3;
               panel.add(new JLabel("Depart Date:"), gBC);

               gBC.gridy = 4;
               panel.add(new JLabel("Return Date:"), gBC);

               gBC.gridy = 5;
               panel.add(new JLabel("Cutoff Date:"), gBC);

               gBC.gridy = 6;
               panel.add(new JLabel("Description:"), gBC);

               gBC.gridy = 7;
               panel.add(new JLabel("SEARCH:"), gBC);

               // COLUMN 2
               gBC.gridx = 1;
               gBC.gridy = 0;
               panel.add(nameTF, gBC);

               gBC.gridy = 1;
               panel.add(costTF, gBC);

               gBC.gridy = 2;
               panel.add(defaultRaiseGoalTF, gBC);

               gBC.gridy = 3;
               panel.add(departDateTF, gBC);

               gBC.gridy = 4;
               panel.add(returnDateTF, gBC);

               gBC.gridy = 5;
               panel.add(cutoffDateTF, gBC);

               gBC.gridy = 6;
               gBC.gridwidth = 2;
               panel.add(descriptionTF, gBC);

               gBC.gridy = 7;
               gBC.gridwidth = 1;
               panel.add(searchTF, gBC);

               // COLUMN 3
               gBC.gridx = 2;
               gBC.gridy = 3;
               gBC.anchor = GridBagConstraints.WEST;
               panel.add(departBTN, gBC);

               gBC.gridy = 4;
               panel.add(returnBTN, gBC);

               gBC.gridy = 5;
               panel.add(cutoffBTN, gBC);

               gBC.gridy = 7;
               panel.add(tripList, gBC);
               tripList.setPreferredSize(new Dimension(180, 20));
               tripList.setMinimumSize(new Dimension(180, 20));
               tripList.setMaximumSize(new Dimension(180, 20));

               // INITIALIZE ALL TEXTFIELDS TO THE FIRST TRIP
               String tripSelected = tripList.getSelectedItem().toString();
               tripID = ArraySorter.idFinder(trips, tripSelected);

               try
               {
                  // UPDATE TRIP INFO ON SCREEN
                  ArrayList<Object> allTripInfo = DBconnection.getTrips(tripID);
                  String allTrip = allTripInfo.toString();
                  String[] results = allTrip.split(",");
                  nameTF.setText(results[1].substring(1));
                  descriptionTF.setText(results[2].substring(1));
                  costTF.setText(results[3].substring(1));
                  defaultRaiseGoalTF.setText(results[4].substring(1));
                  departDateTF.setText(results[5].substring(1));
                  returnDateTF.setText(results[6].substring(1));
                  cutoffDateTF.setText(results[7].substring(1, results[7].length() - 2));
               }
               catch (SQLException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
               catch (ClassNotFoundException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }

               final JFrame f = new JFrame();
               f.getContentPane().add(panel);
               f.pack();

    // LISTENERS FOR DATE PICKER BUTTONS
       departBTN.addActionListener(new ActionListener() 
       {

           @Override
           public void actionPerformed(ActionEvent ae) 
           {               
               // Check if depart date is before return date
               String datePicked = new DatePicker(f).setPickedDate();
               DateFormat formatter;
               Date dateReturn, dateDepart;
               formatter = new SimpleDateFormat("yyyy-MM-dd");
               
              
              if (!returnDateTF.getText().isEmpty())
              {
                    try 
                    {
                        dateReturn = (Date) formatter.parse(returnDateTF.getText());
                        dateDepart = (Date) formatter.parse(datePicked);
                        if (dateReturn.after(dateDepart)) 
                        {
                            departDateTF.setText(datePicked);
                        }
                        else
                        {
                            departDateTF.setText("");
                            new Warnings("Depart date can not be after Cutoff date!sssss");
                        }
                    } catch (ParseException ex) {
                        Logger.getLogger(Trips.class.getName()).log(Level.SEVERE, null, ex);
                    }
                  
              }
              else
              {
                  departDateTF.setText(datePicked);
              }

               try 
               {
                   if (!departDateTF.getText().isEmpty())
                   {    
                       dateDepart = (Date) formatter.parse(departDateTF.getText());
                       Calendar cal = Calendar.getInstance();
                       cal.setTime(dateDepart);
                       cal.add(Calendar.MONTH, -6);
                       dateDepart = cal.getTime();
                       cutoffDateTF.setText(formatter.format(dateDepart));
                   }
               } catch (ParseException ex) {
                   Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
           }
       });
       returnBTN.addActionListener(new ActionListener() 
       {

           @Override
           public void actionPerformed(ActionEvent ae) 
           {
               String datePicked = new DatePicker(f).setPickedDate();
               DateFormat formatter;
               Date dateReturn, dateDepart;
               formatter = new SimpleDateFormat("yyyy-MM-dd");
               try 
               {
                   if (!departDateTF.getText().isEmpty())
                   {
                       dateReturn = (Date) formatter.parse(datePicked);
                       dateDepart = (Date) formatter.parse(departDateTF.getText());

                       if (dateReturn.after(dateDepart)) 
                       {
                           returnDateTF.setText(datePicked);
                       } 
                       else 
                       {
                           returnDateTF.setText("");
                           new Warnings("Return date can not be before the depart date!");
                       }
                   }
                   else
                   {
                       returnDateTF.setText(datePicked);
                   }

               } catch (ParseException ex) {
                   Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
           }
       });
       cutoffBTN.addActionListener(new ActionListener() 
       {

           @Override
           public void actionPerformed(ActionEvent ae) 
           {
               cutoffDateTF.setText(new DatePicker(f).setPickedDate());
           }
       });

               searchTF.addKeyListener(
                  new KeyListener()
                  {
                     @Override
                     public void keyTyped(KeyEvent e)
                     {
                     }

                     @Override
                     public void keyPressed(KeyEvent e)
                     {
                     }

                     @Override
                     public void keyReleased(KeyEvent e)
                     {
                        JTextField textField = (JTextField) e.getSource();
                        String text = textField.getText();
                        textField.setText(text);
                        try
                        {
                           updateComboBox();
                        }
                        catch (SQLException ex)
                        {
                           Logger.getLogger(Fundraisers.class.getName()).log(Level.SEVERE, null, ex);
                        }
                        catch (ClassNotFoundException ex)
                        {
                           Logger.getLogger(Fundraisers.class.getName()).log(Level.SEVERE, null, ex);
                        }
                     }

                     // **************************************UPDATES THE COMBO BOX TO REFLECT ALL FUNDRAISERS MATCHING SEARCH CRITERIA
                     private void updateComboBox() throws SQLException, ClassNotFoundException
                     {
                        Object[] tripsNames = tripsFormatted.toArray();

                        Pattern p = Pattern.compile(searchTF.getText(), Pattern.CASE_INSENSITIVE);
                        tripList.removeAllItems();
                        for (int i = 0; i < tripsNames.length; i++)
                        {
                           String elem = tripsNames[i].toString();
                           Matcher m = p.matcher(elem);
                           if (m.find())
                           {
                              tripList.addItem(tripsNames[i]);
                           }
                        }
                     }
                  });

               // ITEM LISTENER FOR COMBO BOX
               tripList.addItemListener(
                  new ItemListener()
                  {
                     @Override
                     public void itemStateChanged(ItemEvent e)
                     {
                        // WHEN SOMEONE IS SELECTED FROM THE COMBOBOX GET THEIR INFORMATION
                        if (e.getStateChange() == ItemEvent.DESELECTED)
                        {
                        }
                        if (e.getStateChange() == ItemEvent.SELECTED)
                        {
                           String tripSelected = tripList.getSelectedItem().toString();
                           tripID = ArraySorter.idFinder(trips, tripSelected);

                           try
                           {
                              // UPDATE TRIP INFO ON SCREEN
                              ArrayList<Object> allTripInfo = DBconnection.getTrips(tripID);
                              String allTrip = allTripInfo.toString();
                              String[] results = allTrip.split(",");
                              nameTF.setText(results[1].substring(1));
                              descriptionTF.setText(results[2].substring(1));
                              costTF.setText(results[3].substring(1));
                              defaultRaiseGoalTF.setText(results[4].substring(1));
                              departDateTF.setText(results[5].substring(1));
                              returnDateTF.setText(results[6].substring(1));
                              cutoffDateTF.setText(results[7].substring(1, results[7].length() - 2));
                           }
                           catch (SQLException ex)
                           {
                              Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                           }
                           catch (ClassNotFoundException ex)
                           {
                              Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                           }
                        }
                     }
                  });

               // DISPLAY selected persons information
               int result = JOptionPane.showConfirmDialog(null, panel, "UPDATE TRIP",
                  JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);

               // *****************************************IF 'OK' IS HIT VERYIFY.  OTHERWISE CANCEL
               if (result == JOptionPane.OK_OPTION)
               {
                  // CALL TO UPDATE DATABASE
                  try
                  {
                     DBconnection.updateTrip(tripID + "", nameTF.getText(), descriptionTF.getText(), costTF.getText(),
                        defaultRaiseGoalTF.getText(), departDateTF.getText(), returnDateTF.getText(), cutoffDateTF.getText());
                  }
                  catch (ParseException ex)
                  {
                     Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                  }
                  catch (SQLException ex)
                  {
                     Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                  }
                  catch (ClassNotFoundException ex)
                  {
                     Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                  }
               }
            }
         });

      addPicturesTripJMI.addActionListener(
         new ActionListener()
         {
            JTextField photo1, photo2, photo3, photo4, photo5;
            JButton picBTN1, picBTN2, picBTN3, picBTN4, picBTN5;
            JFileChooser photoFC;
            FileFilter photoFilter = new FileNameExtensionFilter("Image Files", "jpg", "png");
            File photoFile1, photoFile2, photoFile3, photoFile4, photoFile5;
            BufferedImage photoImage;
            JComboBox tripList;
            ArrayList<Object> trips, tripsFormatted;
            int tripID;

            @Override
            public void actionPerformed(ActionEvent e)
            {
               UIManager.put("OptionPane.okButtonText", "UPLOAD");
               photoFC = new JFileChooser();
               photoFC.setFileFilter(photoFilter);
               photo1 = new JTextField(10);
               photo1.setEditable(false);
               photo2 = new JTextField(10);
               photo2.setEditable(false);
               photo3 = new JTextField(10);
               photo3.setEditable(false);
               photo4 = new JTextField(10);
               photo4.setEditable(false);
               photo5 = new JTextField(10);
               photo5.setEditable(false);
               picBTN1 = new JButton("BROWSE");
               picBTN2 = new JButton("BROWSE");
               picBTN3 = new JButton("BROWSE");
               picBTN4 = new JButton("BROWSE");
               picBTN5 = new JButton("BROWSE");
               try
               {
                  trips = DBconnection.getTrips();
                  tripsFormatted = ArraySorter.sortArray(trips);
               }
               catch (SQLException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
               catch (ClassNotFoundException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
               tripList = new JComboBox(tripsFormatted.toArray());

               final JPanel panel = new JPanel(new GridBagLayout());
               GridBagConstraints gBC = new GridBagConstraints();
               gBC.anchor = GridBagConstraints.WEST;


               // COLUMN 1
               gBC.weightx = 1;
               gBC.weighty = 1;
               gBC.gridx = 0;
               gBC.gridy = 0;
               panel.add(new JLabel("First Picture:"), gBC);

               gBC.gridy = 1;
               panel.add(new JLabel("Second Picture:"), gBC);

               gBC.gridy = 2;
               panel.add(new JLabel("Third Picture:"), gBC);

               gBC.gridy = 3;
               panel.add(new JLabel("Fourth Picture:"), gBC);

               gBC.gridy = 4;
               panel.add(new JLabel("Fifth Picture:"), gBC);

               // COLUMN 2
               gBC.gridx = 1;
               gBC.gridy = 0;
               panel.add(photo1, gBC);

               gBC.gridy = 1;
               panel.add(photo2, gBC);

               gBC.gridy = 2;
               panel.add(photo3, gBC);

               gBC.gridy = 3;
               panel.add(photo4, gBC);

               gBC.gridy = 4;
               panel.add(photo5, gBC);

               gBC.gridy = 5;
               panel.add(tripList, gBC);

               // COLUMN 3
               gBC.gridx = 2;
               gBC.gridy = 0;
               panel.add(picBTN1, gBC);

               gBC.gridy = 1;
               panel.add(picBTN2, gBC);

               gBC.gridy = 2;
               panel.add(picBTN3, gBC);

               gBC.gridy = 3;
               panel.add(picBTN4, gBC);

               gBC.gridy = 4;
               panel.add(picBTN5, gBC);

               final JFrame f = new JFrame();
               f.getContentPane().add(panel);
               f.pack();

               // LISTENERS FOR DATE PICKER BUTTONS
               picBTN1.addActionListener(new ActionListener()
               {
                  @Override
                  public void actionPerformed(ActionEvent ae)
                  {
                     if (photoFC.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
                     {
                        photoFile1 = photoFC.getSelectedFile();
                        photo1.setText(photoFile1.getName());
                     }
                  }
               });
               picBTN2.addActionListener(new ActionListener()
               {
                  @Override
                  public void actionPerformed(ActionEvent ae)
                  {
                     if (photoFC.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
                     {
                        photoFile2 = photoFC.getSelectedFile();
                        photo2.setText(photoFile2.getName());
                     }
                  }
               });
               picBTN3.addActionListener(new ActionListener()
               {
                  @Override
                  public void actionPerformed(ActionEvent ae)
                  {
                     if (photoFC.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
                     {
                        photoFile3 = photoFC.getSelectedFile();
                        photo3.setText(photoFile3.getName());
                     }
                  }
               });
               picBTN4.addActionListener(new ActionListener()
               {
                  @Override
                  public void actionPerformed(ActionEvent ae)
                  {
                     if (photoFC.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
                     {
                        photoFile4 = photoFC.getSelectedFile();
                        photo4.setText(photoFile4.getName());
                     }
                  }
               });
               picBTN5.addActionListener(new ActionListener()
               {
                  @Override
                  public void actionPerformed(ActionEvent ae)
                  {
                     if (photoFC.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
                     {
                        photoFile5 = photoFC.getSelectedFile();
                        photo5.setText(photoFile5.getName());
                     }
                  }
               });

               // DISPLAY selected persons information
               int result = JOptionPane.showConfirmDialog(null, panel, "UPLOAD PICTURES",
                  JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);

               // *****************************************IF 'OK' IS HIT VERYIFY.  OTHERWISE CANCEL
               if (result == JOptionPane.OK_OPTION)
               {
                  // GET THE TRIP TO UPDATE PHOTOS TO
                  String tripSelected = tripList.getSelectedItem().toString();
                  tripID = ArraySorter.idFinder(trips, tripSelected);

                  // CHECK TO SEE IF EACH FILE IS NULL OR NOT
                  if (photoFile1 != null)
                  {
                     try
                     {
                        photoImage = ImageIO.read(photoFile1);
                        photoImage = Util.resizeImage(photoImage, 150, 130);
                        try
                        {
                           DBconnection.addTripPhoto(tripID, photoImage);
                        }
                        catch (SQLException ex)
                        {
                           Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                        }
                        catch (ClassNotFoundException ex)
                        {
                           Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                        }
                     }
                     catch (IOException ex)
                     {
                        Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                     }
                  }
                  if (photoFile2 != null)
                  {
                     try
                     {
                        photoImage = ImageIO.read(photoFile2);
                        photoImage = Util.resizeImage(photoImage, 150, 130);
                        try
                        {
                           DBconnection.addTripPhoto(tripID, photoImage);
                        }
                        catch (SQLException ex)
                        {
                           Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                        }
                        catch (ClassNotFoundException ex)
                        {
                           Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                        }
                     }
                     catch (IOException ex)
                     {
                        Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                     }
                  }
                  if (photoFile3 != null)
                  {
                     try
                     {
                        photoImage = ImageIO.read(photoFile3);
                        photoImage = Util.resizeImage(photoImage, 150, 130);
                        try
                        {
                           DBconnection.addTripPhoto(tripID, photoImage);
                        }
                        catch (SQLException ex)
                        {
                           Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                        }
                        catch (ClassNotFoundException ex)
                        {
                           Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                        }
                     }
                     catch (IOException ex)
                     {
                        Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                     }
                  }
                  if (photoFile4 != null)
                  {
                     try
                     {
                        photoImage = ImageIO.read(photoFile4);
                        photoImage = Util.resizeImage(photoImage, 150, 130);
                        try
                        {
                           DBconnection.addTripPhoto(tripID, photoImage);
                        }
                        catch (SQLException ex)
                        {
                           Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                        }
                        catch (ClassNotFoundException ex)
                        {
                           Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                        }
                     }
                     catch (IOException ex)
                     {
                        Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                     }
                  }
                  if (photoFile5 != null)
                  {
                     try
                     {
                        photoImage = ImageIO.read(photoFile5);
                        photoImage = Util.resizeImage(photoImage, 150, 130);
                        try
                        {
                           DBconnection.addTripPhoto(tripID, photoImage);
                        }
                        catch (SQLException ex)
                        {
                           Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                        }
                        catch (ClassNotFoundException ex)
                        {
                           Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                        }
                     }
                     catch (IOException ex)
                     {
                        Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                     }
                  }

                  // RESET ALL photoFiles TO NULL SO THEY DON'T GET UPLOADED AGAIN WHEN THEY SHOULDN'T BE
                  photoFile1 = null;
                  photoFile2 = null;
                  photoFile3 = null;
                  photoFile4 = null;
                  photoFile5 = null;
               }
            }
         });

      // *****************************************LISTENER FOR THE ADD TRIPS FUNCTION
      addTripJMI.addActionListener(
         new ActionListener()
         {
            JTextField nameTF;
            JTextArea descriptionTF;
            JTextField costTF;
            JTextField defaultRaiseGoalTF;
            JTextField departDateTF;
            JTextField returnDateTF;
            JTextField cutoffDateTF;
            JButton departBTN;
            JButton returnBTN;
            JButton cutoffBTN;

            @Override
            public void actionPerformed(ActionEvent e)
            {
               UIManager.put("OptionPane.okButtonText", "ADD TRIP");
               nameTF = new JTextField(12);
               descriptionTF = new JTextArea(4, 30);
               descriptionTF.setBorder(BorderFactory.createLineBorder(Color.WHITE));
               costTF = new JTextField(12);
               defaultRaiseGoalTF = new JTextField(12);
               departDateTF = new JTextField(12);
               returnDateTF = new JTextField(12);
               cutoffDateTF = new JTextField(12);
               departBTN = new JButton("PICK DATE");
               returnBTN = new JButton("PICK DATE");
               cutoffBTN = new JButton("PICK DATE");
               UIManager.put("TextArea.font", nameTF.getFont());

               final JPanel panel = new JPanel(new GridBagLayout());
               GridBagConstraints gBC = new GridBagConstraints();
               gBC.anchor = GridBagConstraints.WEST;

               // COLUMN 1
               gBC.weightx = 1;
               gBC.weighty = 1;
               gBC.gridx = 0;
               gBC.gridy = 0;
               panel.add(new JLabel("Name:"), gBC);

               gBC.gridy = 1;
               panel.add(new JLabel("Cost:"), gBC);

               gBC.gridy = 2;
               panel.add(new JLabel("Raise Goal:"), gBC);

               gBC.gridy = 3;
               panel.add(new JLabel("Depart Date:"), gBC);

               gBC.gridy = 4;
               panel.add(new JLabel("Return Date:"), gBC);

               gBC.gridy = 5;
               panel.add(new JLabel("Cutoff Date:"), gBC);

               gBC.gridy = 6;
               panel.add(new JLabel("Description:"), gBC);

               // COLUMN 2
               gBC.gridx = 1;
               gBC.gridy = 0;
               panel.add(nameTF, gBC);

               gBC.gridy = 1;
               panel.add(costTF, gBC);

               gBC.gridy = 2;
               panel.add(defaultRaiseGoalTF, gBC);

               gBC.gridy = 3;
               panel.add(departDateTF, gBC);

               gBC.gridy = 4;
               panel.add(returnDateTF, gBC);

               gBC.gridy = 5;
               panel.add(cutoffDateTF, gBC);

               gBC.gridy = 6;
               gBC.gridwidth = 2;
               panel.add(descriptionTF, gBC);

               // COLUMN 3
               gBC.gridx = 2;
               gBC.gridy = 3;
               gBC.gridwidth = 1;
               gBC.anchor = GridBagConstraints.WEST;
               panel.add(departBTN, gBC);

               gBC.gridy = 4;
               panel.add(returnBTN, gBC);

               gBC.gridy = 5;
               panel.add(cutoffBTN, gBC);

               final JFrame f = new JFrame();
               f.getContentPane().add(panel);
               f.pack();

       // LISTENERS FOR DATE PICKER BUTTONS
       departBTN.addActionListener(new ActionListener() 
       {

           @Override
           public void actionPerformed(ActionEvent ae) 
           {               
               // Check if depart date is before return date
               String datePicked = new DatePicker(f).setPickedDate();
               DateFormat formatter;
               Date dateReturn, dateDepart;
               formatter = new SimpleDateFormat("yyyy-MM-dd");
               
              
              if (!returnDateTF.getText().isEmpty())
              {
                    try 
                    {
                        dateReturn = (Date) formatter.parse(returnDateTF.getText());
                        dateDepart = (Date) formatter.parse(datePicked);
                        if (dateReturn.after(dateDepart)) 
                        {
                            departDateTF.setText(datePicked);
                        }
                        else
                        {
                            departDateTF.setText("");
                            new Warnings("Depart date can not be after Cutoff date!sssss");
                        }
                    } catch (ParseException ex) {
                        Logger.getLogger(Trips.class.getName()).log(Level.SEVERE, null, ex);
                    }
                  
              }
              else
              {
                  departDateTF.setText(datePicked);
              }

               try 
               {
                   if (!departDateTF.getText().isEmpty())
                   {    
                       dateDepart = (Date) formatter.parse(departDateTF.getText());
                       Calendar cal = Calendar.getInstance();
                       cal.setTime(dateDepart);
                       cal.add(Calendar.MONTH, -6);
                       dateDepart = cal.getTime();
                       cutoffDateTF.setText(formatter.format(dateDepart));
                   }
               } catch (ParseException ex) {
                   Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
           }
       });
       returnBTN.addActionListener(new ActionListener() 
       {

           @Override
           public void actionPerformed(ActionEvent ae) 
           {
               String datePicked = new DatePicker(f).setPickedDate();
               DateFormat formatter;
               Date dateReturn, dateDepart;
               formatter = new SimpleDateFormat("yyyy-MM-dd");
               try 
               {
                   if (!departDateTF.getText().isEmpty())
                   {
                       dateReturn = (Date) formatter.parse(datePicked);
                       dateDepart = (Date) formatter.parse(departDateTF.getText());

                       if (dateReturn.after(dateDepart)) 
                       {
                           returnDateTF.setText(datePicked);
                       } 
                       else 
                       {
                           returnDateTF.setText("");
                           new Warnings("Return date can not be before the depart date!");
                       }
                   }
                   else
                   {
                       returnDateTF.setText(datePicked);
                   }

               } catch (ParseException ex) {
                   Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
           }
       });
       cutoffBTN.addActionListener(new ActionListener() 
       {

           @Override
           public void actionPerformed(ActionEvent ae) 
           {
               cutoffDateTF.setText(new DatePicker(f).setPickedDate());
           }
       });
               // DISPLAY selected persons information
               int result = JOptionPane.showConfirmDialog(null, panel, "ADD NEW TRIP",
                  JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);

               // *****************************************IF 'OK' IS HIT VERYIFY.  OTHERWISE CANCEL
               if (result == JOptionPane.OK_OPTION)
               {
                  try
                  {
                     // CALL TO ADD TRIP TO DB
                     DBconnection.addExpedition(nameTF.getText(), descriptionTF.getText(), costTF.getText(),
                        defaultRaiseGoalTF.getText(), departDateTF.getText(), returnDateTF.getText(),
                        cutoffDateTF.getText());
                  }
                  catch (ParseException ex)
                  {
                     Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                  }
                  catch (SQLException ex)
                  {
                     Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                  }
                  catch (ClassNotFoundException ex)
                  {
                     Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                  }
               }
            }
         });
      //******************************************END OF ADD TRIP JMENU LISTENER

      // *****************************************LISTENER FOR THE ADD PERSON FUNCTION
      addPersonJMI.addActionListener(
         new ActionListener()
         {
            JTextField firstNameTF, middleNameTF, lastNameTF, phoneTF, emailTF, streetTF, raiseGoalTF, cityTF, stateTF, zipTF;
            JFileChooser photoFC;
            JCheckBox donor;
            JCheckBox fundraiser;
            JCheckBox admin;
            FileFilter photoFilter = new FileNameExtensionFilter("Image Files", "jpg", "png");
            JTextField photoTF;
            JTextArea notesTA;
            JButton browseBTN;
            JTextField passwordTF;
            JComboBox expeditionsList, peoplesList;
            File photoFile;
            BufferedImage photoImage;
            ArrayList<Object> tripsList, formattedTrips, personsList, formattedPersons;

            @Override
            public void actionPerformed(ActionEvent e)
            {
               UIManager.put("OptionPane.okButtonText", "ADD PERSON");
               firstNameTF = new JTextField(12);
               middleNameTF = new JTextField(12);
               lastNameTF = new JTextField(12);
               phoneTF = new JTextField(12);
               emailTF = new JTextField(12);
               streetTF = new JTextField(12);
               raiseGoalTF = new JTextField(12);
               cityTF = new JTextField(12);
               stateTF = new JTextField(2);
               zipTF = new JTextField(5);
               photoFC = new JFileChooser();
               photoFC.setFileFilter(photoFilter);
               photoTF = new JTextField(12);
               photoTF.setEditable(false);
               browseBTN = new JButton("BROWSE");
               passwordTF = new JPasswordField(12);
               donor = new JCheckBox("Donor?");
               fundraiser = new JCheckBox("Fundraiser?");
               admin = new JCheckBox("Admin?");
               notesTA = new JTextArea(4, 40);
               try
               {
                  tripsList = DBconnection.getTrips();
                  formattedTrips = ArraySorter.sortArray(tripsList);
                  personsList = DBconnection.getPeople();
                  formattedPersons = ArraySorter.sortArray(personsList);
               }
               catch (SQLException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
               catch (ClassNotFoundException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
               expeditionsList = new JComboBox(formattedTrips.toArray());
               peoplesList = new JComboBox(formattedPersons.toArray());
               JPanel panel = new JPanel(new GridBagLayout());
               GridBagConstraints gBC = new GridBagConstraints();
               gBC.anchor = GridBagConstraints.WEST;

               // COLUMN 1
               gBC.weightx = 1;
               gBC.weighty = 1;
               gBC.gridx = 0;
               gBC.gridy = 0;
               panel.add(new JLabel("First:"), gBC);

               gBC.gridy = 1;
               panel.add(new JLabel("Phone:"), gBC);

               gBC.gridy = 2;
               panel.add(new JLabel("E-Mail:"), gBC);

               gBC.gridy = 3;
               panel.add(new JLabel("Raise Goal:"), gBC);

               gBC.gridy = 4;
               panel.add(new JLabel("Expedition:"), gBC);

               gBC.gridy = 5;
               panel.add(new JLabel("Referred By:"), gBC);

               gBC.gridy = 6;
               panel.add(fundraiser, gBC);

               gBC.gridy = 7;
               panel.add(donor, gBC);

               gBC.gridy = 8;
               panel.add(admin, gBC);

               // COLUMN 2
               gBC.gridx = 1;
               gBC.gridy = 0;
               panel.add(firstNameTF, gBC);

               gBC.gridy = 1;
               panel.add(phoneTF, gBC);

               gBC.gridy = 2;
               panel.add(emailTF, gBC);

               gBC.gridy = 3;
               panel.add(raiseGoalTF, gBC);

               gBC.gridy = 4;
               gBC.fill = GridBagConstraints.HORIZONTAL;
               panel.add(expeditionsList, gBC);

               gBC.gridy = 5;
               panel.add(peoplesList, gBC);

               gBC.gridy = 6;
               gBC.anchor = GridBagConstraints.EAST;
               gBC.fill = GridBagConstraints.NONE;
               panel.add(new JLabel("Notes:"), gBC);

               // COLUMN 3
               gBC.gridx = 2;
               gBC.gridy = 0;
               gBC.anchor = GridBagConstraints.WEST;
               panel.add(new JLabel("Middle:"), gBC);

               gBC.gridy = 1;
               panel.add(new JLabel("Address:"), gBC);

               gBC.gridy = 2;
               panel.add(new JLabel("City:"), gBC);

               gBC.gridy = 4;
               panel.add(new JLabel("Picture:"), gBC);

               gBC.gridy = 5;
               panel.add(new JLabel("Password:"), gBC);

               gBC.gridy = 6;
               gBC.gridwidth = 4;
               gBC.gridheight = 4;
               panel.add(notesTA, gBC);

               // COLUMN 4
               gBC.gridx = 3;
               gBC.gridy = 0;
               gBC.gridwidth = 1;
               gBC.gridheight = 1;
               panel.add(middleNameTF, gBC);

               gBC.gridy = 1;
               panel.add(streetTF, gBC);

               gBC.gridy = 2;
               panel.add(cityTF, gBC);

               gBC.gridy = 4;
               panel.add(photoTF, gBC);

               gBC.gridy = 5;
               panel.add(passwordTF, gBC);

               // COLUMN 5
               gBC.gridx = 4;
               gBC.gridy = 0;
               panel.add(new JLabel("Last:"), gBC);

               gBC.gridy = 2;
               panel.add(new JLabel("State:"), gBC);

               gBC.gridy = 3;
               panel.add(new JLabel("Zip:"), gBC);

               // COLUMN 6
               gBC.gridx = 5;
               gBC.gridy = 0;
               panel.add(lastNameTF, gBC);

               gBC.gridy = 2;
               panel.add(stateTF, gBC);

               gBC.gridy = 3;
               panel.add(zipTF, gBC);

               gBC.gridy = 4;
               panel.add(browseBTN, gBC);

               // GET DEFAULT TRIP AND SET DEFAULRAISEGOAL
               // GET SELECTED TRIPID AND USE IT TO GET DEFAULT RAISE GOAL
               int tripSelected = expeditionsList.getSelectedIndex();
               String tripID = tripsList.get(tripSelected).toString();
               tripID = tripID.substring((tripID.lastIndexOf(',') + 2), (tripID.length() - 1));
               // GET DEFAULT RAISE GOAL
               try
               {
                  String raiseGoal = DBconnection.getRaiseGoal(Integer.parseInt(tripID));
                  raiseGoalTF.setText(raiseGoal);
               }
               catch (SQLException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
               catch (ClassNotFoundException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }

               // *****************************************LISTENER FOR EXPEDITIONS LIST, TO GET DEFAULT RAISE GOAL
               expeditionsList.addActionListener(
                  new ActionListener()
                  {
                     @Override
                     public void actionPerformed(ActionEvent ae)
                     {
                        // GET SELECTED TRIPID AND USE IT TO GET DEFAULT RAISE GOAL
                        int tripSelected = expeditionsList.getSelectedIndex();
                        String tripID = tripsList.get(tripSelected).toString();
                        tripID = tripID.substring((tripID.lastIndexOf(',') + 2), (tripID.length() - 1));
                        // GET DEFAULT RAISE GOAL
                        try
                        {
                           String raiseGoal = DBconnection.getRaiseGoal(Integer.parseInt(tripID));
                           raiseGoalTF.setText(raiseGoal);
                        }
                        catch (SQLException ex)
                        {
                           Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                        }
                        catch (ClassNotFoundException ex)
                        {
                           Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                        }
                     }
                  });

               // *****************************************ADD LISTENER TO BROWSE BUTTON
               browseBTN.addActionListener(
                  new ActionListener()
                  {
                     @Override
                     public void actionPerformed(ActionEvent ae)
                     {
                        // GETS THE APPROVED PICTURE AND STORES IT AS THE photoFILE TO BE UPLOADED
                        if (photoFC.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
                        {
                           photoFile = photoFC.getSelectedFile();
                           photoTF.setText(photoFile.getName());
                        }
                     }
                  });

               // DISPLAY selected persons information
               int result = JOptionPane.showConfirmDialog(null, panel, "ADD NEW PERSONS",
                  JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);

               // *****************************************IF 'OK' IS HIT VERYIFY.  OTHERWISE CANCEL
               if (result == JOptionPane.OK_OPTION)
               {
                  // GET THE PICTURE AND MAKE IT A BUFFEREDIMAGE
                  //UPDATE PICTURE
                  if (photoFile != null)
                  {
                     try
                     {
                        photoImage = ImageIO.read(photoFile);
                        photoImage = Util.resizeImage(photoImage, 200, 200);
                     }
                     catch (IOException ex)
                     {
                        Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                     }
                  }
                  else
                  {
                     try
                     {
                        photoImage = Util.resizeImage(ImageIO.read(new File("default.jpg")), 200, 200);
                     }
                     catch (IOException ex)
                     {
                        Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                     }
                  }

                  // CALL TO UPDATE THE DATABASE
                  try
                  {
                     int selected = peoplesList.getSelectedIndex();
                     String personID = personsList.get(selected).toString();
                     personID = personID.substring((personID.lastIndexOf(',') + 2), (personID.length() - 1));

                     DBconnection.addPerson(firstNameTF.getText(), middleNameTF.getText(),
                        lastNameTF.getText(), phoneTF.getText(), emailTF.getText(),
                        streetTF.getText(), cityTF.getText(), stateTF.getText(), zipTF.getText(),
                        photoImage, SimpleSHA1.SHA1(passwordTF.getText()), notesTA.getText(), Integer.parseInt(personID));

                     // CHECK IF PERSON NEEDS TO BE ADDED TO DONORS TABLE
                     if (donor.isSelected())
                     {
                        DBconnection.insertPersonIntoDonors(emailTF.getText());
                        Donors.updateDonorList();
                     }

                     // CHECK IF PERSON NEEDS TO BE ADDED TO FUNDRAISERS TABLE
                     if (fundraiser.isSelected())
                     {
                        int selectedExpedition = expeditionsList.getSelectedIndex();
                        String expeditionID = tripsList.get(selectedExpedition).toString();
                        expeditionID = expeditionID.substring((expeditionID.lastIndexOf(',') + 2), (expeditionID.length() - 1));
                        DBconnection.insertPersonIntoFundraisers(emailTF.getText(), raiseGoalTF.getText(), Integer.parseInt(expeditionID));
                        Fundraisers.updateFundraiserList();
                     }

                     // CHECK IF PERSON NEEDS TO BE ADDED TO ADMIN TABLE
                     if (admin.isSelected())
                     {
                        DBconnection.insertPersonIntoAdmins(emailTF.getText());
                     }

                     DBconnection.closeConnection();
                  }
                  catch (IOException ex)
                  {
                     Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                  }
                  catch (NoSuchAlgorithmException ex)
                  {
                     Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                  }
                  catch (SQLException ex)
                  {
                     Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                  }
                  catch (ClassNotFoundException ex)
                  {
                     Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                  }

                  // RESET THE PHOTO TO NULL FOR FUTURE UPDATES
                  photoFile = null;
               }
            }
         });
      //******************************************END OF ADD PERSON JMENU LISTENER

      // *****************************************LISTENER FOR THE CHANGE ROLES FUNCTION
      changeRolesJMI.addActionListener(
         new ActionListener()
         {
            JTextField searchTF;
            JComboBox personsList;
            JCheckBox fundraiserCB;
            JCheckBox donorCB;
            JCheckBox adminCB;
            ArrayList<Object> peopleList, formattedPeople;
            boolean adminStatus;
            boolean fundraiserStatus;
            boolean donorStatus;
            int personID;

            @Override
            public void actionPerformed(ActionEvent e)
            {

               UIManager.put("OptionPane.okButtonText", "UPDATE");
               //CALL TO GET ALL PEOPLE, RETURN ARRAY LIST AND SET THAT AS COMBOBOX ARRAY
               try
               {
                  peopleList = DBconnection.getPeople();
                  formattedPeople = ArraySorter.sortArray(peopleList);
                  personsList = new JComboBox(formattedPeople.toArray());
               }
               catch (SQLException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
               catch (ClassNotFoundException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }
               searchTF = new JTextField(12);
               fundraiserCB = new JCheckBox("Fundraiser?");
               donorCB = new JCheckBox("Donor?");
               adminCB = new JCheckBox("Admin?");
               adminStatus = false;
               fundraiserStatus = false;
               donorStatus = false;

               final JPanel panel = new JPanel(new GridBagLayout());
               panel.setPreferredSize(new Dimension(280, 80));
               panel.setMinimumSize(new Dimension(280, 80));
               panel.setMaximumSize(new Dimension(280, 80));
               GridBagConstraints gBC = new GridBagConstraints();
               gBC.anchor = GridBagConstraints.WEST;

               // COLUMN 1
               gBC.weightx = 1;
               gBC.weighty = 1;
               gBC.gridx = 0;
               gBC.gridy = 0;
               panel.add(new JLabel("SEARCH:"), gBC);

               gBC.gridy = 1;
               gBC.fill = GridBagConstraints.HORIZONTAL;
               panel.add(searchTF, gBC);

               gBC.gridy = 2;
               panel.add(personsList, gBC);
               personsList.setPreferredSize(new Dimension(180, 20));
               personsList.setMinimumSize(new Dimension(180, 20));
               personsList.setMaximumSize(new Dimension(180, 20));

               // COLUMN 2
               gBC.gridx = 2;
               gBC.gridy = 0;
               gBC.fill = GridBagConstraints.NONE;
               panel.add(fundraiserCB, gBC);

               gBC.gridy = 1;
               panel.add(donorCB, gBC);

               gBC.gridy = 2;
               panel.add(adminCB, gBC);

               searchTF.addKeyListener(
                  new KeyListener()
                  {
                     @Override
                     public void keyTyped(KeyEvent e)
                     {
                     }

                     @Override
                     public void keyPressed(KeyEvent e)
                     {
                     }

                     @Override
                     public void keyReleased(KeyEvent e)
                     {
                        JTextField textField = (JTextField) e.getSource();
                        String text = textField.getText();
                        textField.setText(text);
                        try
                        {
                           updateComboBox();
                        }
                        catch (SQLException ex)
                        {
                           Logger.getLogger(Fundraisers.class.getName()).log(Level.SEVERE, null, ex);
                        }
                        catch (ClassNotFoundException ex)
                        {
                           Logger.getLogger(Fundraisers.class.getName()).log(Level.SEVERE, null, ex);
                        }
                     }

                     // **************************************UPDATES THE COMBO BOX TO REFLECT ALL FUNDRAISERS MATCHING SEARCH CRITERIA
                     private void updateComboBox() throws SQLException, ClassNotFoundException
                     {
                        Object[] personsNames = formattedPeople.toArray();

                        Pattern p = Pattern.compile(searchTF.getText(), Pattern.CASE_INSENSITIVE);
                        personsList.removeAllItems();
                        for (int i = 0; i < personsNames.length; i++)
                        {
                           String elem = personsNames[i].toString();
                           Matcher m = p.matcher(elem);
                           if (m.find())
                           {
                              personsList.addItem(personsNames[i]);
                           }
                        }
                     }
                  });

               // ITEM LISTENER FOR COMBO BOX
               personsList.addItemListener(
                  new ItemListener()
                  {
                     @Override
                     public void itemStateChanged(ItemEvent e)
                     {
                        // WHEN SOMEONE IS SELECTED FROM THE COMBOBOX GET THEIR INFORMATION
                        if (e.getStateChange() == ItemEvent.DESELECTED)
                        {
                        }
                        if (e.getStateChange() == ItemEvent.SELECTED)
                        {
                           String personSelected = personsList.getSelectedItem().toString();
                           personID = ArraySorter.idFinder(peopleList, personSelected);
                           try
                           {
                              // UPDATE CHECK BOXES
                              if (DBconnection.isAdmin(personID))
                              {
                                 adminCB.setSelected(true);
                                 adminStatus = true;
                              }
                              else
                              {
                                 adminCB.setSelected(false);
                                 adminStatus = false;
                              }
                              if (DBconnection.isFundraiser(personID))
                              {
                                 fundraiserCB.setSelected(true);
                                 fundraiserStatus = true;
                              }
                              else
                              {
                                 fundraiserCB.setSelected(false);
                                 fundraiserStatus = false;
                              }
                              if (DBconnection.isDonor(personID))
                              {
                                 donorCB.setSelected(true);
                                 donorStatus = true;
                              }
                              else
                              {
                                 donorCB.setSelected(false);
                                 donorStatus = false;
                              }
                           }
                           catch (SQLException ex)
                           {
                              Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                           }
                           catch (ClassNotFoundException ex)
                           {
                              Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                           }

                        }
                     }
                  });
               // END OF ITEM LISTENER FOR COMBO BOX

               // DISPLAY selected persons information
               int result = JOptionPane.showConfirmDialog(null, panel, "UPDATE ROLES",
                  JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);

               // *****************************************IF 'OK' IS HIT VERYIFY.  OTHERWISE CANCEL
               if (result == JOptionPane.OK_OPTION)
               {
                  final ArrayList<Object> tripsList, tripsFormatted;
                  final JComboBox expeditionsList;
                  final JTextField raiseGoalMoreTF;
                  // CALLS TO UPDATE DB TABLES
                  try
                  {
                     // IF ADMIN WAS NOT INITIALLY SELECTED BUT IS NOW, ADD TO ADMINS TABLE
                     if (adminStatus == false && adminCB.isSelected())
                     {
                        DBconnection.insertPersonIntoAdmins(personID);
                        // NOW PERSON IS IN ADMINS SO..
                        adminStatus = true;
                     }
                     // IF FUNDRAISER WAS NOT INITIALLY SELECTED BUT IS NOW, ADD TO FUNRAISERS TABLE
                     if (fundraiserStatus == false && fundraiserCB.isSelected())
                     {
                        //NEED TO GET MORE INFORMATION (expeditionId and raiseGoal)
                        final JPanel panelMore = new JPanel(new GridBagLayout());
                        raiseGoalMoreTF = new JTextField(12);
                        tripsList = DBconnection.getTrips();
                        tripsFormatted = ArraySorter.sortArray(tripsList);
                        expeditionsList = new JComboBox(tripsFormatted.toArray());
                        gBC.anchor = GridBagConstraints.WEST;

                        // COLUMN 1
                        gBC.weightx = 1;
                        gBC.weighty = 1;
                        gBC.gridx = 0;
                        gBC.gridy = 0;
                        panelMore.add(new JLabel("Expedition:"), gBC);

                        gBC.gridy = 1;
                        panelMore.add(new JLabel("Raise Goal:"), gBC);

                        // COLUMN 2
                        gBC.gridx = 1;
                        gBC.gridy = 0;
                        panelMore.add(expeditionsList, gBC);

                        gBC.gridy = 1;
                        panelMore.add(raiseGoalMoreTF, gBC);

                        // GET DEFAULT TRIP AND SET DEFAULRAISEGOAL
                        // GET SELECTED TRIPID AND USE IT TO GET DEFAULT RAISE GOAL
                        int tripSelected = expeditionsList.getSelectedIndex();
                        String tripID = tripsList.get(tripSelected).toString();
                        tripID = tripID.substring((tripID.lastIndexOf(',') + 2), (tripID.length() - 1));
                        // GET DEFAULT RAISE GOAL
                        try
                        {
                           String raiseGoal = DBconnection.getRaiseGoal(Integer.parseInt(tripID));
                           raiseGoalMoreTF.setText(raiseGoal);
                        }
                        catch (SQLException ex)
                        {
                           Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                        }
                        catch (ClassNotFoundException ex)
                        {
                           Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                        }

                        // *****************************************LISTENER FOR EXPEDITIONS LIST, TO GET DEFAULT RAISE GOAL
                        expeditionsList.addActionListener(
                           new ActionListener()
                           {
                              @Override
                              public void actionPerformed(ActionEvent ae)
                              {
                                 // GET SELECTED TRIPID AND USE IT TO GET DEFAULT RAISE GOAL
                                 int tripSelected = expeditionsList.getSelectedIndex();
                                 String tripID = tripsList.get(tripSelected).toString();
                                 tripID = tripID.substring((tripID.lastIndexOf(',') + 2), (tripID.length() - 1));
                                 // GET DEFAULT RAISE GOAL
                                 try
                                 {
                                    String raiseGoal = DBconnection.getRaiseGoal(Integer.parseInt(tripID));
                                    raiseGoalMoreTF.setText(raiseGoal);
                                 }
                                 catch (SQLException ex)
                                 {
                                    Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                                 }
                                 catch (ClassNotFoundException ex)
                                 {
                                    Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                                 }
                              }
                           });

                        int moreInfo = JOptionPane.showConfirmDialog(null, panelMore, "UPDATE ROLES",
                           JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
                        // *****************************************IF 'OK' IS HIT VERYIFY.  OTHERWISE CANCEL
                        if (moreInfo == JOptionPane.OK_OPTION)
                        {
                           int selectedTrip = expeditionsList.getSelectedIndex();
                           String expeditionID = tripsList.get(selectedTrip).toString();
                           expeditionID = expeditionID.substring((expeditionID.lastIndexOf(',') + 2), (expeditionID.length() - 1));
                           DBconnection.insertPersonIntoFundraisers(personID, raiseGoalMoreTF.getText(), Integer.parseInt(expeditionID));
                           Fundraisers.updateFundraiserList();
                           // NOW PERSON IS FUNDRAISER SO..
                           fundraiserStatus = true;
                        }
                     }
                     // IF DONOR WAS NOT INITIALLY SELECTED BUT IS NOW, ADD TO DONORS TABLE
                     if (donorStatus == false && donorCB.isSelected())
                     {
                        DBconnection.insertPersonIntoDonors(personID);
                        Donors.updateDonorList();
                        // NOW PERSON IS DONOR SO..
                        donorStatus = true;
                     }
                  }
                  catch (SQLException ex)
                  {
                     Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                  }
                  catch (ClassNotFoundException ex)
                  {
                     Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
                  }
               }
            }
         });
      //******************************************END OF CHANGE ROLE JMENU LISTENER

      aboutMenu.addActionListener(
         new ActionListener()
         {
            BufferedImage aboutLogo = ImageIO.read(new File("aboutLogo.jpg"));

            @Override
            public void actionPerformed(ActionEvent e)
            {
               UIManager.put("OptionPane.okButtonText", "DONE");

               final JPanel panel = new JPanel();
               panel.setPreferredSize(new Dimension(400, 400));

               try
               {
                  aboutLogo = Util.resizeImage(ImageIO.read(new File("aboutLogo.jpg")), 400, 200);
               }
               catch (IOException ex)
               {
                  Logger.getLogger(EPovertyMain.class.getName()).log(Level.SEVERE, null, ex);
               }

               JEditorPane info = new JEditorPane();
               info.setContentType("text/html");
               info.setText("<html><font color=white><b>This program was made for Eliminating Poverty <br>"
                  + "By the CIS 2770 Spring of 2012 class. <br><br>"
                  + "Project participants: </b><br><br>"
                  + "<i>Tyrel Mortensen<br>"
                  + "Bunna Veth<br>"
                  + "Clark Endrizzi<br>"
                  + "Daniel Baker<br>"
                  + "Brandon Free<br>"
                  + "Brian Walsh</i></font>");
               info.setPreferredSize(new Dimension(400, 200));
               JScrollPane scroll = new JScrollPane(info);
               scroll.setBorder(borderGreen);
               info.setBackground(Color.DARK_GRAY);
               JLabel logo = new JLabel("");
               logo.setIcon(new ImageIcon(aboutLogo));

               panel.add(logo, BorderLayout.PAGE_START);
               panel.add(scroll, BorderLayout.PAGE_END);
               panel.revalidate();

               final JFrame f = new JFrame();
               f.getContentPane().add(panel);
               f.pack();

               int moreInfo = JOptionPane.showConfirmDialog(null, panel, "About e-Poverty",
                  JOptionPane.PLAIN_MESSAGE, JOptionPane.PLAIN_MESSAGE);
            }
         });
      //The below items will run reports from the Report class.
      donorsLastDonationJMI.addActionListener(
         new ActionListener()
         {
            @Override
            public void actionPerformed(ActionEvent e)
            {
                Report.donorsLastDonation();                   
            }
         });
      //******************************************This just makes sure that everything is drawn correctly on the screen
      this.validate();
   }
//*********************************************END OF CONSTRUCTOR
// ********************************************METHOD TO ADD A WITHDRAWAL FROM MENU OPTIONS

   public static void addWithdrawal(int account) throws SQLException, ClassNotFoundException, ParseException
   {
      UIManager.put("OptionPane.okButtonText", "ADD WITHDRAWAL");
      final JPanel panel = new JPanel(new GridBagLayout());
      GridBagConstraints gBC = new GridBagConstraints();
      final JFrame f = new JFrame();
      f.getContentPane().add(panel);
      f.pack();

      //GET ACCOUNT BY NAME FOR VISUAL IDENTIFIER ON SCREEN
      String accountName;
      switch (account)
      {
         case 1:
            accountName = "OVERHEAD";
            break;
         case 2:
            accountName = "TRIPS";
            break;
         case 3:
            accountName = "CHARITY";
            break;
         default:
            accountName = "";
            break;
      }

      JButton dateBTN = new JButton("Date");
      JTextField payToTF = new JTextField(12);
      JTextField amountTF = new JTextField(12);
      final JTextField dateTF = new JTextField(12);
      JTextArea descriptionTA = new JTextArea(4, 30);
      gBC.anchor = GridBagConstraints.WEST;

      // COLUMN 1
      gBC.weightx = 1;
      gBC.weighty = 1;
      gBC.gridx = 0;
      gBC.gridy = 0;
      panel.add(new JLabel("Pay To:"), gBC);

      gBC.gridy = 1;
      panel.add(new JLabel("Amount:"), gBC);

      gBC.gridy = 2;
      panel.add(new JLabel("Date: "), gBC);

      gBC.gridy = 3;
      panel.add(new JLabel("Description:"), gBC);

      gBC.gridy = 4;
      gBC.gridwidth = 3;
      panel.add(descriptionTA, gBC);

      // COLUMN 2
      gBC.gridy = 0;
      gBC.gridx = 1;
      gBC.gridwidth = 1;
      panel.add(payToTF, gBC);

      gBC.gridy = 1;
      panel.add(amountTF, gBC);

      gBC.gridy = 2;
      panel.add(dateTF, gBC);

      // COLUMN 3
      gBC.gridx = 2;
      panel.add(dateBTN, gBC);

      // LISTENER TO BUTTON
      dateBTN.addActionListener(new ActionListener()
      {
         @Override
         public void actionPerformed(ActionEvent ae)
         {
            dateTF.setText(new DatePicker(f).setPickedDate());
         }
      });

      int moreInfo = JOptionPane.showConfirmDialog(null, panel, ("ADD WITHDRAWAL TO " + accountName + " ACCOUNT"),
         JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
      // *****************************************IF 'OK' IS HIT VERYIFY.  OTHERWISE CANCEL
      if (moreInfo == JOptionPane.OK_OPTION)
      {
         DBconnection.insertWithdrawalFromAccount(account, new BigDecimal(amountTF.getText().toString()),
            payToTF.getText(), descriptionTA.getText(), dateTF.getText());
      }
   }

   //Prevents cells from being edited in table by overriding isCellEditable.
   public class myTable extends DefaultTableModel
   {
      @Override
      public boolean isCellEditable(int row, int col)
      {
         return false;
      }
   }

   /*
    * This method is so that all of our tab
    * classes can change the status message on the
    * bottom of the screen We may want to add a
    * timer to this so that it will erase it after
    * some point? Just an idea.
    */
   public static void updateStatus(String message)
   {
      messages.setText(message);
   }
}
